<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    *{
        padding: 0;
        margin: 0;
    }
    body{
        height: 100%;

    }
    .wrapper{
        width: 600px;
        border: 1px solid red;
        margin: 30opx auto;
    }
    ul{
        list-style: none;
        overflow: hidden;
    }
    ul a{
        display: block;
        text-decoration: none;
        width: 200px;
        height: 50px;
        text-align: center;
        line-height: 50px;
        color: #000;
    }
      ul li{
          float: left;
          background-color: rgba(0, 0, 0, 3);
      }
   p{
       width: 600px;
       height: 150px;
       line-height: 150px;
       text-align: center;
       display: none;
   }
    ul li.active{
        background-color: #ffffff;
    }
    p.active{
        display: none;
    }
</style>
<body>
    <div class="active">
        <ul>
            <li><a href="#">首页</a></li>
            <li><a href="#">新闻</a></li>
            <li><a href="#">热卖</a></li>
        </ul>
        <p id="home" class="active">首页内容</p>
        <p id="news" >新闻内容</p>
        <p id="hotPurchase" >热卖内容</p>

    </div>
</body>
<script>
    var lis=document.getElementsByTagName('li');
    var ps=document.getElementsByTagName('p');
    for(var i=0;i<lis.length;i++){
        lis[i].index=i;
        lis[i].onlick=function(){
            for(var j=0;j<lis.length;j++){
                lis[j].className='';
                 ps[j].className='';
            }
            this.className='active';
            ps[this.index].className='active'
        }
    }
</script>
</html>